package com.margiel.rozkladowka.model;

import java.util.ArrayList;
import java.util.List;

import com.margiel.util.StringUtil;

public class Vehicle {
	private String no;
	private String link;
	private List<TimeTable> timeTables;

	public String getNo() {
		return no;
	}

	public void setNo(String no) {
		this.no = no;
	}

	public String getLink() {
		return link;
	}

	public void setLink(String link) {
		this.link = link;
	}

//	public void addTime(Integer hour, Integer minutes) {
//		List<Integer> minutesList = timeTable.get(hour);
//		if (minutesList == null) {
//			minutesList = new ArrayList<Integer>(10);
//			timeTable.put(hour, minutesList);
//		}
//		minutesList.add(minutes);
//	}

	public List<TimeTable> getTimeTables() {
		return timeTables;
	}

	public void setTimeTables(List<TimeTable> timeTables) {
		this.timeTables = timeTables;
	}

	public Vehicle(String no, String link) {
		super();
		this.no = no;
		this.link = link;
	}

	/**
	 * Constructs a <code>String</code> with all attributes
	 * in name = value format.
	 *
	 * @return a <code>String</code> representation 
	 * of this object.
	 */
	public String toString()
	{
	    final String TAB = "\n    ";
	    final String END = "\n";
	    
	    String retValue = "";
	    
	    retValue = "Vehicle ( "
	        + super.toString() + TAB
	        + "no = " + this.no + TAB
	        + "link = " + this.link + TAB
	        + "TimeTables = " + StringUtil.collectionToString(this.timeTables) + END
	        + " )";
	
	    return retValue;
	}
	
	public void addTimeTable(TimeTable timeTable){
		if (this.timeTables == null){
			this.timeTables = new ArrayList<TimeTable>(2);
		}
		timeTables.add(timeTable);
	}
	
	public boolean hasStop(String stopName){
		if (timeTables!= null){
			for (TimeTable timeTable : timeTables) {
				if (timeTable.getStops() != null){
					for (Stop stop : timeTable.getStops()) {
						if (stop.getName().equals(stopName)){
							return true;
						}
					}
				}
			}
		}
		return false;
	}
	
	
	
	
}
